/**********************************************************************//**
 * @file common.c
 * @brief function summary
 *
 * Development Div. : PI&S SSE SYS1-3\n
 * Author : Yoichiro SATO\n
 * Copyright 2011 Sony Corporation. \n
 * ================================================================== */
/**********************************************************************/

/* --- include files ------------------------------------------------ */
#include "common.h"

/* --- macro definitions -------------------------------------------- */
/* --- structure/class definitions ---------------------------------- */
/* --- function prototypes ------------------------------------------ */
/* --- static values ------------------------------------------------ */
/* --- auto values -------------------------------------------------- */

#ifndef _STK_FOR_SA_
/* ------------------------------------------------------------------ *//**
 * @brief right bit shift
 * @param x [in] input value
 * @param shift [int] shift size
 * @retval shifted value
 */
/* ------------------------------------------------------------------ */
int RIGHT_SHIFT(int x, int shift)
{
	if (x < 0) {
		return (x - (1 << (shift - 1))) >> shift;
	} else {
		return (x + (1 << (shift - 1))) >> shift;
	}
}
/* ------------------------------------------------------------------ *//**
 * @brief right bit shift
 * @param x [in] input value
 * @param shift [int] shift size
 * @retval shifted value
 */
/* ------------------------------------------------------------------ */
int RIGHT_SHIFT_POSITIVE(int x, int shift)
{
    return (x + (1 << (shift - 1))) >> shift;
}
#endif
